<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/5/31
 * Time: 11:26
 */

namespace app\admin\Model;
use think\Db;
use think\Model;

class Member extends Model
{
   // protected $table='test_member';

    public static function  show($where=null){
        if(isset($where)){
            $list=Db::name('test_member')->where($where)->order('member_created_at desc')->paginate();
           // $list=Db::name('test_member')->where(['member_category'=>"首页会员"])->order('member_created_at desc')->paginate();
        }else{
            $list=Db::name('test_member')->order('member_created_at desc')->paginate();
        }
       // $where=['member_state'=>30];
        //$list=Db::table('test_member')->fetchSql(true)->where(['member_state'=>30,'member_status'=>30])->order('member_created_at desc')->paginate();
        return $list;
    }

    public static function  getField($condition,$key=null){
        if(isset($key)){
            $list=Db::name('test_member')->where($condition)->field($key)->find()[$key];
        }else{
            $list=Db::name('test_member')->where($condition)->find();
        }
        return $list;
    }

    public static function change($condition,$data=null){
        $res=Db::name('test_member')->where($condition)->update($data);
        return $res;
    }

    public static function  deleted($condition){
        $res=Db::name('test_member')->where($condition)->delete();
        return $res;
    }

}